package com.javaee.xiangyang.mapper;

import com.javaee.xiangyang.entity.Classify;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface ClassifyMapper {

    /**
     * 此接口只给GoodsMapper接口开放
     */
//    @Select("select * from classify where classifyId = #{classifyId}")
    Classify findByClassifyId(int classifyId);

    /**
     * 增加新的分类
     * 暂时不用  暑假可扩展
     */
//    @Insert("Insert into classify values(#{classifyId}, #{classifyName}, #{classifyDescribe})")
    void addClassifyMapper(Classify classify);

    /**
     * 查看所有分类
     */
//    @Select("select * from classify")
    List<Classify> findAllClassify();

    /**
     * 查看所有分类和所有分类下所有商品
     */
    /*@Select("select * from classify")
    @Results(id = "Classify", value = {

            @Result(id = true, column = "classifyId", property = "classifyId"),
            @Result(
                    column = "classifyId",
                    property = "goodsList",
                    javaType = List.class,
                    many = @Many(select = "com.javaee.xiangyang.mapper.GoodsMapper.findAllGoodsById")
            )
    })*/
    List<Classify> findAllClassifyAndGoods();

    /**
     * 查看当前分类下所有商品
     */
//    @Select("select * from classify where classifyId = #{classifyId}")
//    @ResultMap("Classify")
    Classify findClassifyById(Classify classify);

    /**
     * 修改分类简介
     */
//    @Update("update classify set classifyDescribe = #{classifyDescribe} where classifyId = #{classifyId}")
    void updateDescribeByClassifyId(Classify classify);

    /**
     * 删除对应分类
     * 暂时不用   暑假扩展
     */
//    @Delete("delete from classify where classifyId = #{classifyId}")
    void deleteClassifyByClassifyId(Classify classify);

}
